<template>
<!--  offer-->
  <div class="wo">
    <div class="wenzi">
      <el-form :model="offer" label-width="120px">
        <h2 style="text-align: center">offer</h2>
        <p style="letter-spacing:3px;" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;尊敬的：{{offer.talentsName}}先生/女士</p>
        <p style="letter-spacing:3px;" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;您好!</p>
        <p style="letter-spacing:3px;">&nbsp;感谢您对本公司的信任和肯定，感谢您以耐心、热心并满怀诚意参与公司的面试。</p>
        <p style="letter-spacing:3px;">&nbsp;经过沟通，您的职业素质、专业能力和工作经验赢得我们公司的一致肯定，我们热诚地邀请并欢迎您加入!</p>
        <p style="letter-spacing:3px;">&nbsp;请您仔细阅读以下内容，按要求备齐相关资料，在指定时间内到我公司人力资源部办理入职手续。</p>
        <p style="letter-spacing:3px;">&nbsp;1.任职岗位</p>
        <p style="letter-spacing:3px;">&nbsp;&nbsp;拟聘任您担任 <input v-model="offer.postName"  style="width: 70px"/> 岗位，所属部门 <input v-model="offer.deptName"  style="width: 60px"/> 。</p>
        <p style="letter-spacing:3px;">&nbsp;⒉报到情况</p>
        <p style="letter-spacing:3px;">&nbsp;&nbsp;入职时间:
          <el-date-picker
              v-model="offer.offerDate"
              type="date"
              placeholder="请选择"
              style="width: 140px"
          />
      </p>
        <p style="letter-spacing:3px;">&nbsp;&nbsp;报到地点: <input style="width: 70px" v-model="offer.offerPlace"/></p>
        <p style="letter-spacing:3px;">&nbsp;3.入职需准备和携带的材料</p>
        <p style="letter-spacing:3px;">&nbsp;&nbsp;身份证、学历证、学位证、资质证书、职称证书的原件及复印件。一寸照片10张。</p>
        <p style="letter-spacing:3px;">&nbsp;&nbsp;近期体检报告一份。</p>
        <p style="letter-spacing:3px;">&nbsp;&nbsp;最后任职企业的离职证明。</p>
        <p style="letter-spacing:3px;">&nbsp;4.薪酬/合同</p>
        <p style="letter-spacing:3px;">&nbsp; &nbsp;试用期基本薪酬: <input v-model="offer.offerSalary"  style="width: 70px"/> 元人民币/月。</p>
        <p style="letter-spacing:3px;">&nbsp; &nbsp;转正后基本薪酬: <input v-model="offer.offerFormalsalary"  style="width: 70px"/> 元人民币/月。</p>
        <p style="letter-spacing:3px;">&nbsp; &nbsp;试用期为 <input v-model="offer.offerProbation"  style="width: 20px"/> 个月。</p>
        <p style="letter-spacing:3px;">&nbsp;期待您给我们的团队带来新的活力,希望您工作愉快、事业有成!</p>
        <p style="letter-spacing:3px;">&nbsp;  能力有限公司人力资源部</p>

        <el-form-item>
          <el-button v-if="offer.offerState == 0" type="primary" @click="onSubmit()">确认发送</el-button>
          <el-button v-if="offer.offerState == 1" type="primary" @click="onSubmit()">已发送</el-button>
          <el-button>取消</el-button>
        </el-form-item>
      </el-form>
  </div>
  </div>
</template>

<script lang="ts" setup>
import {onBeforeMount, reactive} from "vue";
import {useRouter} from "vue-router";
import axios from "axios";
//获取当前时间
import moment from 'moment';
import {useStore} from "vuex";
import {ElMessage} from "element-plus";
let riqi2 = moment(new Date()).format("YYYY-MM-DD")


let router=useRouter();
const offers=()=>{
  let talentsId =router.currentRoute.value.query
  console.log(talentsId)
  if(talentsId != '' ){
    axios.post("personnelOa/offer/cxoffer/"+talentsId["id"])
        .then((res)=>{
          details(res.data.data);
          console.log(offer)
        })
  }
}
let offer = reactive({
  offerId:'',
  talentsId:'',
  talentsName:'',
  offerDepartment:'',
  deptName:'',
  offerPost:'',
  postName:'',
  offerSalary:'',
  offerFormalsalary:'',
  offerProbation:'',
  offerDate:'',
  offerDates:'',
  offerPlace:'',
  offerState:'',
  //入职申请数据
  aspiringSector:'',
  aspiringPost:'',
  recSex:'',
  recEMail:'',
  recruitsSalary:'',

})
const details = (row)=>{
  offer.offerId = row.offerId
  offer.talentsId = row.talentsId
  offer.offerDepartment = row.offerDepartment
  offer.offerPost = row.offerPost
  offer.offerSalary = row.offerSalary
  offer.offerFormalsalary = row.offerFormalsalary
  offer.offerProbation = row.offerProbation
  offer.offerDate =row.offerDate
  offer.offerDates = row.offerDates;
  offer.offerPlace = row.offerPlace;
  offer.deptName = row.dept.deptName
  offer.postName = row.post.postName
  offer.talentsName = row.talentpool.talentsName
  offer.offerState = row.offerState;
  offer.aspiringSector= row.offerDepartment
  offer.aspiringPost= row.offerPost
  offer.recSex= row.talentpool.talentsSex
  offer.recEMail= row.talentpool.talentsMailbox
  offer.recruitsSalary= row.offerFormalsalary

}
//确认发送按钮
const onSubmit = () => {
  console.log(offer)
  axios.post("personnelOa/offer/upOffer",offer).then((res)=>{
    if (res.data.data>0){
      ElMessage({
        type: 'success',
        message: '发送成功',
      })
      aaa();
      fanhui();
    }
  })
}
const aaa =()=>{
  axios.post("personnelOa/recruits/addrecruits",offer).then((res)=>{
  })
}
const fanhui=()=>{
  router.go(-1);
}
//一进页面就调用
onBeforeMount(()=>{
  offers();
})

</script>

<style scoped>
.wo{
  width: 100%;

  border: 0px solid #e5e3e3;
}
.wenzi{
  width: 800px;
  border: 0px red solid;
  margin: 0px auto;
  margin-top: 40px;
}
</style>